home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.FlowLayout;
- import java.awt.FontMetrics;
- import java.awt.GridLayout;
- import java.awt.Label;
- import java.awt.Panel;
- import java.awt.TextArea;
- import java.awt.TextField;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.net.URL;
- import java.util.EventObject;
-
- public class TextEncrypter extends Applet implements ActionListener {
- // $FF: renamed from: wi int
- private int field_0;
- // $FF: renamed from: he int
- private int field_1;
- private boolean isFondhex = false;
- private Color color;
- private Color backColor;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_2;
- // $FF: renamed from: p1 java.awt.Panel
- private Panel field_3;
- // $FF: renamed from: p2 java.awt.Panel
- private Panel field_4;
- // $FF: renamed from: p3 java.awt.Panel
- private Panel field_5;
- // $FF: renamed from: p4 java.awt.Panel
- private Panel field_6;
- private TextField key;
- private TextArea ta1;
- private TextArea ta2;
- // $FF: renamed from: b1 java.awt.Button
- private Button field_7;
- // $FF: renamed from: b2 java.awt.Button
- private Button field_8;
- // $FF: renamed from: b3 java.awt.Button
- private Button field_9;
- private String text1;
- private String text2;
- private String text3;
- private String text4;
-
- public String getAppletInfo() {
- return "Name: TextEncrypter\r\nAuthor: Taiji Software\r\n";
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- ((Applet)this).stop();
- } catch (Exception e) {
- System.out.println(e);
- ((Applet)this).stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var9) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- ((Container)this).setLayout(new GridLayout(3, 1));
- this.field_3 = new Panel();
- this.field_4 = new Panel();
- this.field_5 = new Panel();
- ((Container)this).add(this.field_3);
- ((Container)this).add(this.field_4);
- ((Container)this).add(this.field_5);
- this.field_3.setLayout(new GridLayout(3, 3));
- this.field_4.setLayout(new GridLayout(1, 2));
- this.field_5.setLayout(new GridLayout(3, 1));
- this.field_3.add(new Label(this.text1));
- this.key = new TextField();
- this.field_3.add(this.key);
- this.field_3.add(new Label(""));
- this.field_3.add(new Label(""));
- this.field_3.add(new Label(""));
- this.field_3.add(new Label(""));
- this.field_3.add(new Label(""));
- this.field_3.add(new Label(""));
- this.field_3.add(new Label(""));
- this.ta1 = new TextArea("", 4, 30);
- this.field_4.add(this.ta1);
- this.ta2 = new TextArea("", 4, 30);
- this.ta2.setEditable(false);
- this.field_4.add(this.ta2);
- this.field_7 = new Button(this.text2);
- this.field_8 = new Button(this.text3);
- this.field_9 = new Button(this.text4);
- this.field_5.add(new Label(""));
- Panel p32 = new Panel(new FlowLayout());
- ((Container)p32).add(this.field_7);
- ((Container)p32).add(this.field_8);
- ((Container)p32).add(this.field_9);
- this.field_5.add(p32);
- this.field_7.addActionListener(this);
- this.field_8.addActionListener(this);
- this.field_9.addActionListener(this);
- this.field_5.add(new Label(""));
- this.key.setText("");
- this.ta1.setText("");
- }
-
- public void getParameters() {
- this.field_0 = ((Component)this).getSize().width;
- this.field_1 = ((Component)this).getSize().height;
- this.text1 = ((Applet)this).getParameter("text1");
- if (this.text1 == null) {
- this.text1 = "Encrypt key: ";
- }
-
- this.text2 = ((Applet)this).getParameter("text2");
- if (this.text2 == null) {
- this.text2 = "Encrypt !";
- }
-
- this.text3 = ((Applet)this).getParameter("text3");
- if (this.text3 == null) {
- this.text3 = "Decrypt !";
- }
-
- this.text4 = ((Applet)this).getParameter("text4");
- if (this.text4 == null) {
- this.text4 = "Clear";
- }
-
- ((Component)this).setBackground(this.getColor("background_color"));
- }
-
- public Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public void actionPerformed(ActionEvent evt) {
- if (((EventObject)evt).getSource() instanceof Button) {
- String label = ((Button)((EventObject)evt).getSource()).getLabel();
- System.out.println(label);
- if (label.equals(this.text4)) {
- this.ta1.setText("");
- this.ta2.setText("");
- return;
- }
-
- String text = this.ta1.getText();
- String keytext = this.key.getText();
- System.out.println(keytext);
- if (keytext.length() == 0) {
- System.out.println("oui");
- this.key.setText("Enter a key here !");
- return;
- }
-
- if (text.length() == 0) {
- this.ta1.setText("Enter a text here !");
- return;
- }
-
- if (label.equals(this.text2)) {
- this.ta2.setText(this.code(1, text, keytext));
- return;
- }
-
- if (label.equals(this.text3)) {
- this.ta2.setText(this.code(-1, text, keytext));
- }
- }
-
- }
-
- public String code(int mode, String text, String key) {
- char[] chars = new char[text.length()];
- text.getChars(0, text.length(), chars, 0);
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < text.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- int m = chars2[j] % 7;
- if (chars2[2] >= 'P') {
- chars[i] = (char)(chars[i] + mode * m);
- } else {
- chars[i] = (char)(chars[i] - mode * m);
- }
- }
-
- return new String(chars);
- }
- }
-